<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		手机号码:<input type ="text" id="input1" />
				
				<script>
					
					input1.onkeydown = function(e){
						console.log("键盘按钮下")
						console.log(e.key);
						console.log(e.keyCode);
						if(e.keyCode<48 || e.keyCode>57) // 数字范围48~57
						{
							// 阻止元素的默认行为
							event.preventDefault()
						}
					}
					
					input1.onkeyup = function(e)
					{
						console.log("键盘抬起")
					}
					
					input1.onkeypress = function(e)
					{
						console.log("键盘按了")
					}
					
					// 只能输入数字不能输入其他字母
					
				</script>
	</body>
</html>
